<?php 
/**create by fu */
namespace app\api\model;

use app\api\model\BaseModel;

/**
 * 
 */
class User extends BaseModel
{
	
	//定义和 UserAddress 模型的关联关系 hasOne(主表模型,主表外键,从表主键)
	public  function address()
	{         //hasOne(主表模型,主表外键,从表主键)
		return $this->hasOne('UserAddress','user_id','id');
	}

	public static function getByOpenID($openid)
	{
		$result = self::where('openid','=',$openid)
		              ->find();

		return $result;
	}

}




 ?>